home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib / tk / menubuttn.man < prev    next >
Encoding:
Text File  |  1992-08-24  |  14.0 KB  |  459 lines

  1. '\"
  2. '\" Copyright 1990 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. '\" $Header: /user6/ouster/wish/man/RCS/menubuttn.man,v 1.12 92/06/03 17:06:50 ouster Exp $ SPRITE (Berkeley)
  11. '/" 
  12. .\" The definitions below are for supplemental macros used in Sprite
  13. .\" manual entries.
  14. .\"
  15. .\" .HS name section [date [version]]
  16. .\"    Replacement for .TH in other man pages.  See below for valid
  17. .\"    section names.
  18. .\"
  19. .\" .AP type name in/out [indent]
  20. .\"    Start paragraph describing an argument to a library procedure.
  21. .\"    type is type of argument (int, etc.), in/out is either "in", "out",
  22. .\"    or "in/out" to describe whether procedure reads or modifies arg,
  23. .\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  24. .\"    needed;  use .AS below instead)
  25. .\"
  26. .\" .AS [type [name]]
  27. .\"    Give maximum sizes of arguments for setting tab stops.  Type and
  28. .\"    name are examples of largest possible arguments that will be passed
  29. .\"    to .AP later.  If args are omitted, default tab stops are used.
  30. .\"
  31. .\" .BS
  32. .\"    Start box enclosure.  From here until next .BE, everything will be
  33. .\"    enclosed in one large box.
  34. .\"
  35. .\" .BE
  36. .\"    End of box enclosure.
  37. .\"
  38. .\" .VS
  39. .\"    Begin vertical sidebar, for use in marking newly-changed parts
  40. .\"    of man pages.
  41. .\"
  42. .\" .VE
  43. .\"    End of vertical sidebar.
  44. .\"
  45. .\" .DS
  46. .\"    Begin an indented unfilled display.
  47. .\"
  48. .\" .DE
  49. .\"    End of indented unfilled display.
  50. .\"
  51. '\"    # Heading for Sprite man pages
  52. .de HS
  53. .if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  54. .if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  55. .if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  56. .if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  57. .if t .wh -1.3i ^B
  58. .nr ^l \\n(.l
  59. .ad b
  60. ..
  61. '\"    # Start an argument description
  62. .de AP
  63. .ie !"\\$4"" .TP \\$4
  64. .el \{\
  65. .   ie !"\\$2"" .TP \\n()Cu
  66. .   el          .TP 15
  67. .\}
  68. .ie !"\\$3"" \{\
  69. .ta \\n()Au \\n()Bu
  70. \&\\$1    \\fI\\$2\\fP    (\\$3)
  71. .\".b
  72. .\}
  73. .el \{\
  74. .br
  75. .ie !"\\$2"" \{\
  76. \&\\$1    \\fI\\$2\\fP
  77. .\}
  78. .el \{\
  79. \&\\fI\\$1\\fP
  80. .\}
  81. .\}
  82. ..
  83. '\"    # define tabbing values for .AP
  84. .de AS
  85. .nr )A 10n
  86. .if !"\\$1"" .nr )A \\w'\\$1'u+3n
  87. .nr )B \\n()Au+15n
  88. .\"
  89. .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  90. .nr )C \\n()Bu+\\w'(in/out)'u+2n
  91. ..
  92. '\"    # BS - start boxed text
  93. '\"    # ^y = starting y location
  94. '\"    # ^b = 1
  95. .de BS
  96. .br
  97. .mk ^y
  98. .nr ^b 1u
  99. .if n .nf
  100. .if n .ti 0
  101. .if n \l'\\n(.lu\(ul'
  102. .if n .fi
  103. ..
  104. '\"    # BE - end boxed text (draw box now)
  105. .de BE
  106. .nf
  107. .ti 0
  108. .mk ^t
  109. .ie n \l'\\n(^lu\(ul'
  110. .el \{\
  111. .\"    Draw four-sided box normally, but don't draw top of
  112. .\"    box if the box started on an earlier page.
  113. .ie !\\n(^b-1 \{\
  114. \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  115. .\}
  116. .el \}\
  117. \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  118. .\}
  119. .\}
  120. .fi
  121. .br
  122. .nr ^b 0
  123. ..
  124. '\"    # VS - start vertical sidebar
  125. '\"    # ^Y = starting y location
  126. '\"    # ^v = 1 (for troff;  for nroff this doesn't matter)
  127. .de VS
  128. .mk ^Y
  129. .ie n 'mc \s12\(br\s0
  130. .el .nr ^v 1u
  131. ..
  132. '\"    # VE - end of vertical sidebar
  133. .de VE
  134. .ie n 'mc
  135. .el \{\
  136. .ev 2
  137. .nf
  138. .ti 0
  139. .mk ^t
  140. \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  141. .sp -1
  142. .fi
  143. .ev
  144. .\}
  145. .nr ^v 0
  146. ..
  147. '\"    # Special macro to handle page bottom:  finish off current
  148. '\"    # box/sidebar if in box/sidebar mode, then invoked standard
  149. '\"    # page bottom macro.
  150. .de ^B
  151. .ev 2
  152. 'ti 0
  153. 'nf
  154. .mk ^t
  155. .if \\n(^b \{\
  156. .\"    Draw three-sided box if this is the box's first page,
  157. .\"    draw two sides but no top otherwise.
  158. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  159. .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  160. .\}
  161. .if \\n(^v \{\
  162. .nr ^x \\n(^tu+1v-\\n(^Yu
  163. \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  164. .\}
  165. .bp
  166. 'fi
  167. .ev
  168. .if \\n(^b \{\
  169. .mk ^y
  170. .nr ^b 2
  171. .\}
  172. .if \\n(^v \{\
  173. .mk ^Y
  174. .\}
  175. ..
  176. '\"    # DS - begin display
  177. .de DS
  178. .RS
  179. .nf
  180. .sp
  181. ..
  182. '\"    # DE - end display
  183. .de DE
  184. .fi
  185. .RE
  186. .sp .5
  187. ..
  188. .HS menubutton cmds
  189. .BS
  190. '\" Note:  do not modify the .SH NAME line immediately below!
  191. .SH NAME
  192. menubutton \- Create and manipulate menubutton widgets
  193. .SH SYNOPSIS
  194. \fBmenubutton\fI \fIpathName \fR?\fIoptions\fR?
  195. .SH "STANDARD OPTIONS"
  196. .LP
  197. .nf
  198. .VS
  199. .ta 4c 8c 12c
  200. \fBactiveBackground\fR    \fBbitmap\fR    \fBfont\fR    \fBrelief\fR
  201. \fBactiveForeground\fR    \fBborderWidth\fR    \fBforeground\fR    \fBtext\fR
  202. \fBanchor\fR    \fBcursor\fR    \fBpadX\fR    \fBtextVariable\fR
  203. \fBbackground\fR    \fBdisabledForeground\fR    \fBpadY\fR    \fBunderline\fR
  204. .VE
  205. .fi
  206. .LP
  207. See the ``options'' manual entry for details on the standard options.
  208. .SH "WIDGET-SPECIFIC OPTIONS"
  209. .ta 4c
  210. .LP
  211. .nf
  212. .VS
  213. Name:    \fBheight\fR
  214. Class:    \fBHeight\fR
  215. Command-Line Switch:    \fB\-height\fR
  216. .fi
  217. .IP
  218. Specifies a desired height for the menu button.
  219. If a bitmap is being displayed in the menu button then the value is in
  220. screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
  221. for text it is in lines of text.
  222. If this option isn't specified, the menu button's desired height is computed
  223. from the size of the bitmap or text being displayed in it.
  224. .VE
  225. .LP
  226. .nf
  227. Name:    \fBmenu\fR
  228. Class:    \fBMenuName\fR
  229. Command-Line Switch:    \fB\-menu\fR
  230. .fi
  231. .IP
  232. Specifies the path name of the menu associated with this menubutton.
  233. .LP
  234. .nf
  235. Name:    \fBstate\fR
  236. Class:    \fBState\fR
  237. Command-Line Switch:    \fB\-state\fR
  238. .fi
  239. .IP
  240. Specifies one of three states for the menu button:  \fBnormal\fR, \fBactive\fR,
  241. or \fBdisabled\fR.  In normal state the menu button is displayed using the
  242. \fBforeground\fR and \fBbackground\fR options.  The active state is
  243. typically used when the pointer is over the menu button.  In active state
  244. the menu button is displayed using the \fBactiveForeground\fR and
  245. \fBactiveBackground\fR options.  Disabled state means that the menu button
  246. is insensitive:  it doesn't activate and doesn't respond to mouse
  247. button presses.  In this state the \fBdisabledForeground\fR and
  248. \fBbackground\fR options determine how the button is displayed.
  249. .LP
  250. .nf
  251. Name:    \fBvariable\fR
  252. Class:    \fBVariable\fR
  253. Command-Line Switch:    \fB\-variable\fR
  254. .fi
  255. .IP
  256. Specifies the name of a global variable to set whenever this menubutton
  257. posts its menu.  Also serves as name of group of related menubuttons
  258. (allows event sharing between menubuttons and menus).  Defaults
  259. to \fBpostedMenu\fR.
  260. .LP
  261. .nf
  262. .VS
  263. Name:    \fBwidth\fR
  264. Class:    \fBWidth\fR
  265. Command-Line Switch:    \fB\-width\fR
  266. .fi
  267. .IP
  268. Specifies a desired width for the menu button.
  269. If a bitmap is being displayed in the menu button then the value is in
  270. screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
  271. for text it is in characters.
  272. If this option isn't specified, the menu button's desired width is computed
  273. from the size of the bitmap or text being displayed in it.
  274. .VE
  275. .BE
  276.  
  277. .SH INTRODUCTION
  278. .PP
  279. The \fBmenubutton\fR command creates a new window (given by the
  280. \fIpathName\fR argument) and makes it into a menubutton widget.
  281. Additional
  282. options, described above, may be specified on the command line
  283. or in the option database
  284. to configure aspects of the menubutton such as its colors, font,
  285. text, and initial relief.  The \fBmenubutton\fR command returns its
  286. \fIpathName\fR argument.  At the time this command is invoked,
  287. there must not exist a window named \fIpathName\fR, but
  288. \fIpathName\fR's parent must exist.
  289. .PP
  290. A menubutton is a widget that displays a
  291. .VS
  292. textual string or bitmap
  293. .VE
  294. and is associated with a menu widget.  In normal usage, pressing
  295. mouse button 1 over the menubutton causes the associated menu to
  296. be posted just underneath the menubutton.  If the mouse is moved over
  297. the menu before releasing the mouse button, the button release
  298. causes the underlying menu entry to be invoked.  When the button
  299. is released, the menu is unposted.
  300. .PP
  301. Menubuttons are organized into groups to allow menu scanning:
  302. if the mouse button is pressed over one menubutton (causing it
  303. to post its menu) and the mouse is moved over another menubutton
  304. in the same group without releasing the mouse button, then the
  305. menu of the first menubutton is unposted and the menu of the
  306. new menubutton is posted instead.
  307. This makes it possible to scan a row of pull-down menus to find a
  308. particular entry.  Typically, all of the menubuttons for an
  309. application are in the same group, but it is possible to assign
  310. multiple groups:  this allows scanning within a group but not
  311. between them.
  312. .PP
  313. Each menubutton is associated with a particular global variable,
  314. determined by the \fBvariable\fR option, and the variable determines
  315. the menubutton's group:  all menubuttons with the same associated
  316. variable are in the same group.  Whenever a
  317. menubutton posts its menu it stores the path name of
  318. .VS
  319. the menubutton in the associated variable.  Furthermore, the
  320. menubutton monitors the value of that variable continuously.
  321. When the variable changes value (e.g. because some other
  322. menubutton posted its menu) then the menubutton will unpost its
  323. menu if the new value is different than the menubutton's name or
  324. post its menu if the new value is the same as the menubutton's name.
  325. This means you can cause a menu to be posted or unposted just by
  326. changing the value of the variable.
  327. .VE
  328.  
  329. .SH "WIDGET COMMAND"
  330. .PP
  331. The \fBmenubutton\fR command creates a new Tcl command whose
  332. name is \fIpathName\fR.  This
  333. command may be used to invoke various
  334. operations on the widget.  It has the following general form:
  335. .DS C
  336. \fIpathName option \fR?\fIarg arg ...\fR?
  337. .DE
  338. \fIOption\fR and the \fIarg\fRs
  339. determine the exact behavior of the command.  The following
  340. commands are possible for menubutton widgets:
  341. .TP
  342. \fIpathName \fBactivate\fR
  343. Change the menu button's state to \fBactive\fR and redisplay the menu
  344. button using its active foreground and background colors instead of normal
  345. colors.
  346. The command returns an empty string.
  347. .VS
  348. This command is ignored if the menu button's state is \fBdisabled\fR.
  349. This command is obsolete and will eventually be removed;
  350. use ``\fIpathName \fBconfigure \-state active\fR'' instead.
  351. .VE
  352. .TP
  353. \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
  354. Query or modify the configuration options of the widget.
  355. If no \fIoption\fR is specified, returns a list describing all of
  356. the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
  357. information on the format of this list).  If \fIoption\fR is specified
  358. with no \fIvalue\fR, then the command returns a list describing the
  359. one named option (this list will be identical to the corresponding
  360. sublist of the value returned if no \fIoption\fR is specified).  If
  361. one or more \fIoption\-value\fR pairs are specified, then the command
  362. modifies the given widget option(s) to have the given value(s);  in
  363. this case the command returns an empty string.
  364. \fIOption\fR may have any of the values accepted by the \fBmenubutton\fR
  365. command.
  366. .TP
  367. \fIpathName \fBdeactivate\fR
  368. Change the menu button's state to \fBnormal\fR and redisplay the menu
  369. button using its normal foreground and background colors.
  370. The command returns an empty string.
  371. .VS
  372. This command is ignored if the menu button's state is \fBdisabled\fR.
  373. This command is obsolete and will eventually be removed;
  374. use ``\fIpathName \fBconfigure \-state normal\fR'' instead.
  375. .VE
  376. .TP
  377. \fIpathName \fBpost\fR
  378. Arrange for the menubutton's associated menu to be posted.  This is
  379. done by executing a Tcl command with the form
  380. .RS
  381. .RS
  382. .IP
  383. \fImenu\fB post \fIx y group\fR
  384. .RE
  385. .RE
  386. .IP
  387. where \fImenu\fR is the path name of the associated menu, \fIx\fR
  388. and \fIy\fR are the root-window coordinates of the lower-left
  389. corner of the menubutton, and \fIgroup\fR is the name of the
  390. menubutton's group (its \fBvariable\fR option).  As a
  391. side effect, the path name of the associated menu is stored in the
  392. global variable associated with the menubutton.  Returns an empty string.
  393. .VS
  394. This command is ignored if the menu button's state is \fBdisabled\fR.
  395. .VE
  396. .TP
  397. \fIpathName \fBunpost\fR
  398. Store an empty string in the variable associated with the
  399. menubutton.  If the menubutton has posted its menu, this will
  400. cause it to unpost its menu by executing a command of the form
  401. .RS
  402. .RS
  403. .IP
  404. \fImenu\fB unpost\fR
  405. .RE
  406. .RE
  407. .IP
  408. where \fImenu\fR is the name of the associated menu.
  409. If any other menubutton sharing
  410. the same variable has posted its menu, then that menubutton
  411. will unpost its menu in a similar fashion.  Returns an empty string.
  412.  
  413. .SH "DEFAULT BINDINGS"
  414. .PP
  415. .VS
  416. Tk automatically creates class bindings for menu buttons that give them
  417. the following default behavior:
  418. .IP [1]
  419. A menu button activates whenever the mouse passes over it and deactivates
  420. whenever the mouse leaves it.
  421. .IP [2]
  422. A menu button's relief is changed to raised whenever mouse button 1 is
  423. pressed over it, and the relief is restored to its original value
  424. when button 1 is later released or the mouse is dragged into another
  425. menu button in the same group.
  426. .IP [3]
  427. When mouse button 1 is pressed over a menu button, or when the mouse
  428. is dragged into a menu button with mouse button 1 pressed, the associated
  429. menu is posted;  the mouse can be dragged across the menu and released
  430. over an entry in the menu to invoke that entry.  The menu is unposted
  431. when button 1 is released outside either the menu or the menu button.
  432. The menu is also unposted when the mouse is dragged into another
  433. menu button in the same group.
  434. .IP [4]
  435. If mouse button 1 is pressed and released within the menu button,
  436. then the menu stays posted and keyboard traversal is possible as
  437. described in the manual entry for \fBtk_menus\fR.
  438. .IP [5]
  439. Menubuttons may also be posted by typing characters on the keyboard.
  440. See the manual entry for \fBtk_menus\fR for full details on keyboard
  441. menu traversal.
  442. .IP [6]
  443. If mouse button 2 is pressed over a menu button then the associated
  444. menu is posted and also \fItorn off\fR:  it can then be dragged around on
  445. the screen with button 2 and the menu will not automatically unpost when
  446. entries in it are invoked.
  447. To close a torn off menu, click mouse button 1 over the associated
  448. menu button.
  449. .PP
  450. If the menu button's state is \fBdisabled\fR then none of the above
  451. actions occur:  the menu button is completely non-responsive.
  452. .PP
  453. The behavior of menu buttons can be changed by defining new bindings for
  454. individual widgets or by redefining the class bindings.
  455. .VE
  456.  
  457. .SH KEYWORDS
  458. menubutton, widget
  459.